# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=gnupg
pkgver=2.1.3
pkgrel=1
pkgdesc='Complete and free implementation of the OpenPGP standard'
url='http://www.gnupg.org/'
license=('GPL')
arch=('i686' 'x86_64')
makedepends=('libassuan-devel'
             'libbz2-devel'
             'libksba-devel'
             'libbz2-devel'
             'libcurl-devel'
             'libgcrypt-devel'
             'libgnutls-devel'
             'libiconv-devel'
             'libnpth-devel'
             'gettext-devel')
depends=('bzip2' 'libassuan' 'libbz2' 'libcurl' 'libgcrypt' 'libgnutls' 'libiconv' 'libintl' 'libksba' 'libnpth' 'pinentry')
source=("ftp://ftp.gnupg.org/gcrypt/${pkgname}/${pkgname}-${pkgver}.tar.bz2"{,.sig}
        'gnupg-2.1.3-msys2.patch')
sha1sums=('091e69ec1ce3f0032e6b135e4da561e8d46d20a7'
          'SKIP'
          'd4bce9d2b224db49a444e571d3096555dca19990')

install=${pkgname}.install

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i ${srcdir}/gnupg-2.1.3-msys2.patch
  
  ./autogen.sh
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure \
    --build=${CHOST} \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --sbindir=/usr/bin \
    --libexecdir=/usr/lib/gnupg \
    --enable-gpgtar \
    --enable-maintainer-mode \
    --disable-dirmngr

  make
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make check
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
  
  ln -s "${pkgdir}"/usr/bin/gpg{2,}
  #ln -s "${pkgdir}"/usr/bin/gpgv{2,}
  ln -s "${pkgdir}"/usr/share/man/man1/gpg{2,}.1
  rm "${pkgdir}/usr/share/gnupg/com-certs.pem" # FS#33059
}
